//
//  HomeNavView.m
//  Rail
//
//  Created by hychen on 2018/3/2.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "HomeNavSearchView.h"

@interface HomeNavSearchView ()
@property (nonatomic, strong) UIView *searchBgView;
@property (nonatomic, strong) UIImageView *iconView;
@property (nonatomic, strong) UILabel *textLabel;
@end
@implementation HomeNavSearchView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self addTapGestureWithTarget:self action:@selector(tapClick)];
        self.searchBgView = [UIView new];
        self.searchBgView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
        self.searchBgView.backgroundColor = RGBA(255, 255, 255, 0.4);
        self.searchBgView.layer.cornerRadius = 15.f;
        self.searchBgView.layer.masksToBounds = YES;
        [self addSubview:self.searchBgView];

        self.iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EVNCustomSearchBar.bundle/searchImageBlack"]];
        self.iconView.frame = CGRectMake(100-28, 6, 18, 18);
        [self.searchBgView addSubview:self.iconView];
        
        self.textLabel = [UILabel labelWithText:@"搜索" textColor:RGBA(40, 40, 40, 1) font:[UIFont systemFontOfSize:13]];
        self.textLabel.frame = CGRectMake(100-28+18+5, 6, 70, 18);
        [self.searchBgView addSubview:self.textLabel];

    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.iconView.frame = CGRectMake((self.frame.size.width-50)*0.5, 7, 18, 18);
    self.textLabel.frame = CGRectMake((self.frame.size.width-50)*0.5 + 23, 7, 70, 18);
}

- (void)tapClick {
    if (self.BlockClickSearch) {
        self.BlockClickSearch();
    }
}

@end
